<template>
  <div class="home">
    <el-container>
      <el-header>
        <img src="../../assets/img/积云.png" alt="" />
        <h2>后台管理系统</h2>
        <el-button @click="homeout" type="info">退出</el-button>
      </el-header>
      <el-container>
        <el-aside :width="isCollapse ? '64px' : '200px'">
          <p @click="isCollapse = !isCollapse" style="color:#fff">|||</p>
          <el-menu
            default-active="/welocme"
            class="el-menu-vertical-demo"
            background-color="#333744"
            text-color="#fff"
            active-text-color="#ffd04b"
            :collapse-transition="true"
            :unique-opened="true"
            :collapse="isCollapse"
            :router="true"
          >
            <el-submenu
              v-for="(item, index) in list"
              :key="item.id"
              :index="item.id + ''"
            >
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item
                :index="'/' + it.path"
                v-for="it in item.children"
                :key="it.id"
                >{{ it.authName }}</el-menu-item
              >
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { HomeApi } from "@/http/api";
export default {
  data() {
    return {
      list: [],
      isCollapse: false,
    };
  },
  components: {},
  created() {
    this.getdata();
  },
  mounted() {},
  methods: {
    async getdata() {
      const res = await HomeApi();
      console.log(res);
      this.list = res;
    },
    homeout() {
      sessionStorage.removeItem("token");
      this.$router.push("/login");
    },
  },
  computed: {},
  watch: {},
};
</script>

<style scoped >
.el-header {
  background-color:#666;
  color: #333;
}
img {
  width: 60px;
  height: 60px;
  border-radius: 5px;
}
.el-aside {
  background-color: #333744;
  color: #333;
  height: 100%;
}

.el-main {
  background-color:  #E9EEF3;
  color: #333;
}

.el-container {
  height: 100%;
}
.home {
  height: 100%;
}
.el-header {
  display: flex;
  justify-content: space-between;
}
p {
  text-align: center;
  cursor: pointer;
}
</style>
